// initialise plugins
jQuery(document).ready(function(){

    //contact form vaildation
    jQuery("#contactForm").validate();
	
    // image hover effect
    jQuery('.viewport').mouseenter(function(e) {
        jQuery(this).children('a').children('img').animate({
            left: '0',
            top: '0',
            width: '110%'
        }, 100);
        jQuery(this).children('a').children('span').fadeIn(200);
    }).mouseleave(function(e) {
        jQuery(this).children('a').children('img').animate({
            left: '0',
            top: '0',
            width: '100%'
        }, 100);
        jQuery(this).children('a').children('span').fadeOut(200);
    });

    // large image scroller
    jQuery('#banner').before('<div id="homebannernav">').cycle({
        fx:     'scrollHorz',
        speed:  'slow',
        timeout: 8000,
        pager:  '#homebannernav',
        next : '.nextButton a',
        prev: '.prevButton a'
    });
	
    // recent scroller
    jQuery('.slider-wrap-recent').cycle({
        fx:     'scrollHorz',
        speed:  'slow',
        timeout: 0,
        next : '.nextrecent',
        prev: '.prevrecent'
    });
	
    // news scroller
    jQuery('.slider-wrap-news').cycle({
        fx:     'scrollHorz',
        speed:  'slow',
        timeout: 0,
        next : '.nextnews',
        prev: '.prevnews'
    });

    /*	jQuery("ul#nav").supersubs({
		dropShadows:   true,
		minWidth:    9,   // minimum width of sub-menus in em units
		maxWidth:    27,   // maximum width of sub-menus in em units
		extraWidth:  2     // extra width can ensure lines don't sometimes turn over 
						   // due to slight rounding differences and font-family
	}).superfish();  // call supersubs first, then superfish, so that subs are
					 // not display:none when measuring. Call before initialising 
					 // containing tabs for same reason. 
      */
    jQuery(document).ready(function(){
        jQuery("ul.sf-menu").superfish({
            pathClass:  'current',
            delay:       500,                                // one second delay on mouseout
            dropShadows:   false,
            animation:   {
                opacity:'show',
                height:'show'
            }  // fade-in and slide-down animation
        // speed:       'fast',                          // faster animation speed
        });
    });
    // portfolio tabs

    // Default Action
    jQuery(".tab_content").hide(); //Hide all content
    if(document.location.hash!='') {
        //get the index from URL hash
        tabSelect = document.location.hash.substr(1,document.location.hash.length);
        //  alert (tabSelect);
        // var urltab =
        jQuery("ul.tabs li#list" + tabSelect).addClass("ui-state-active").show(); //Activate first tab
        jQuery(".tab_content#" + tabSelect).show(); //Show first tab content
        jQuery(window).scrollTo(0);
    //	return false;
    //  $("#my-tabs").tabs('select',tabSelect-1);
    } else {
        jQuery("ul.tabs li:first").addClass("ui-state-active").show(); //Activate first tab
        jQuery(".tab_content:first").show(); //Show first tab content
    }
    // On Click Event
    jQuery("ul.tabs li").click(function(e) {
        jQuery("ul.tabs li").removeClass("ui-state-active"); //Remove any "active" class
        jQuery(this).addClass("ui-state-active"); //Add "active" class to selected tab
        jQuery(".tab_content").hide(); //Hide all tab content
        var activeTab = jQuery(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
        jQuery(activeTab).removeClass("ui-tabs-hide");
        jQuery(activeTab).fadeIn(); //Fade in the active content
        jQuery(activeTab).css("display","block");
        e.preventDefault();
    });
    //Start Tabs
    jQuery(function(){

        // Tabs
        jQuery('#testimonials-tabs').tabs();
        jQuery('#testimonials-tabs ul li a').click(function () {
            //location.hash = jQuery(this).attr('href');
            var activeTab = jQuery(this).attr("href"); //Find the rel attribute value to identify the active tab + content
            jQuery(activeTab).removeClass("ui-tabs-hide");
            jQuery(activeTab).fadeIn(); //Fade in the active content
        } );
    // jQuery(document).ready.window.scrollTo(0, 0);
    });
    //End Tabs
    jQuery(".col-220 img d d").hover(function() {
        jQuery(this).css({
            'z-index' : '999'
        }); /*Add a higher z-index value so this image stays on top*/
        jQuery(this).addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
        .animate({
            marginTop: '-8px', /* The next 4 lines will vertically align this image */
            marginLeft: '-6px',
            top: '50%',
            left: '50%',
            width: '231px', /* Set new width */
            height: '169px', /* Set new height */
            padding: '0'
        }, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
	
    } , function() {
        jQuery(this).css({
            'z-index' : '0'
        }); /* Set z-index back to 0 */
        jQuery(this).removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
        .animate({
            marginTop: '0', /* Set alignment back to default */
            marginLeft: '0',
            top: '0',
            left: '0',
            width: '220px', /* Set width back to default */
            height: '161px', /* Set height back to default */
            padding: '0'
        }, 400);
    });
    // Portfolio Images expand
    jQuery(".portfolioimages").toggle(function() {
        var thisheight = jQuery("img", this).height();
        // alert(thisheight);
        jQuery(".portfolio-mouseover-hint").animate ({
            opacity: 0
        },150);
        jQuery(".portfolio-mouseover-down-hint").delay(1000).animate ({
            opacity: 1
        },350);
        jQuery(this).animate({
            height : thisheight
        }, 1000);
        jQuery(this).attr('title', 'Click to contract this image to default size');
        jQuery(".portfolio-mouseover-down-hint").delay(1500).animate ({
            opacity: 0
        },350);
    }, function() {
        jQuery(this).delay(500).animate({
            height: '490px'
        }, 300);
        jQuery(".portfolio-mouseover-down-hint").animate ({
            opacity: 0
        },0);
        jQuery(".portfolio-mouseover-hint").delay(2000).animate ({
            opacity: 1
        },150);
        jQuery(this).attr('title', 'Click to expand this image to full height');
    });
    // social icon
    // Hide all the tooltips
    jQuery(".social-icons li").each(function() {
        jQuery("a span", this).css("opacity", "0");
    });
    jQuery(".social-icons li").hover(function() { // Mouse over
        jQuery(this)
        .stop().fadeTo(500, 1)
        .siblings().stop().fadeTo(500, 0.2);
			
        jQuery("a span", this)
        .stop()
        .animate({
            opacity: 1,
            top: "30px"
        }, 300); 
    }, function() { // Mouse out
        jQuery(this)
        .stop().fadeTo(500, 1)
        .siblings().stop().fadeTo(500, 1);
		 
        jQuery("a span", this)
        .stop()
        .animate({
            opacity: 0,
            top: "20px"
        }, 300);
    });
    //Smooth Scroll
    jQuery(function( $ ){
        $('a.scroll').click(function(){
            $.scrollTo( this.hash , 1000,{
                axis:'y'
            });
            return false;
        });
    });
// End Smooth Scroll
});
// initialise plugins
jQuery(document).ready(function(){
    //Smooth Scroll
    jQuery(function( $ ){
        $('a.scroll').click(function(){
            $.scrollTo( this.hash , 1000,{
                axis:'y'
            });
            return false;
        });
    });
    // End Smooth Scroll
    function fadeInDivs(elements){
        for(var i=0;i<elements.length;i++){
            elements[i].appear(function(){
                jQuery(this).css('visibility', 'visible')
                .hide()
                .delay(1500).fadeIn(4000);
            //    jQuery(this).effect("scale", { percent: 105}, 500);
            //    jQuery(this).effect("scale", { percent: 100}, 500);
            // The following brace & bracket were missing
            });
        }
    }
    var array = [jQuery('.width33'),jQuery('.creative')];
    jQuery(document).ready(function() {
        fadeInDivs(array);
    });
});
//Select element styling
jQuery(document).ready(function(){
    if (!jQuery.browser.opera) {
        // select element styling
        jQuery('select').each(function(){
            var title = jQuery(this).attr('title');
            if( jQuery('option:selected', this).val() != ''  ) title = jQuery('option:selected',this).text();
            jQuery(this)
            .css({
                'z-index':10
            })
            .change(function(){
                //val = jQuery('option:selected',this).text();
                //jQuery(this).next().text(val);
            })
        });

    };

});
// iframe height resizing
jQuery(document).ready(function() {
    jQuery('.iframe-wrapper').load(function() {
        jQuery(this).height(jQuery(this).contents().find('html')[0].scrollHeight + 25);
    });
});
 //Select element styling

